#define _CRT_SECURE_NO_WARNINGS 1;
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int* ptr = NULL;
	ptr = (int*)malloc(8 * sizeof(int));
	if (ptr == NULL)
	{
		perror("ptr::malloc");
		return 1;
	}
	for (int i = 0; i < 2; i++)
	{
		*(ptr + i) = i;
	}
	printf("%d\n", ptr[0]);
	printf("%d\n", ptr[1]);
	int* ret = NULL;
	ret = (int*)realloc(ptr, 8 * sizeof(int));
	if (ret != NULL)
	{
		ptr = ret;
	}
	else
	{
		perror("ret::realloc");
		return 2;
	}
	for (int i = 2; i < 4; i++)
	{
		*(ptr + i) = i;
	}
	printf("%d\n", ptr[0]);
	printf("%d\n", ptr[1]);
	printf("%d\n", ptr[2]);
	printf("%d\n", ptr[3]);
	free(ptr);
	ptr = NULL;
	return 0;
}